<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Test prototype_ext.js</title>
<script language="JavaScript" type="text/javascript" src="../../lib/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../../lib/test_helper.js"></script>
<script language="JavaScript" type="text/javascript" src="../../lib/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="../../src/logger.js"></script>
<script language="JavaScript" type="text/javascript" src="../../src/prototype_ext.js"></script>
<script language="JavaScript" type="text/javascript" src="../../src/date.js"></script>
<script language="JavaScript" type="text/javascript" src="../../src/calendar.js"></script>
</head>
<body>
<h1>calendar.js Tests</h1>
<p>This page tests loading data documents asynchronously.  To see them, take a look at the source.</p>


<script language="JavaScript" type="text/javascript"><!--
function test_CalendarModel_setValue() {
    var model = new Date.Calendar.Model(new Date("2006/09/16"), Date.EraGroup.DEFAULT_WAREKI);
    assertEquals(Date.Era.HEISEI, model.getValue().getEra());
    assertEquals(2006, model.getValue().getFullYear());
    assertEquals(18, model.getValue().getEraYear());
    assertEquals(8, model.getValue().getMonth());
    assertEquals(16, model.getValue().getDate());
    model.setValue(new Date("1969/10/07"));
    assertEquals(Date.Era.SHOWA, model.getValue().getEra());
    assertEquals(1969, model.getValue().getFullYear());
    assertEquals(44, model.getValue().getEraYear());
    assertEquals(9, model.getValue().getMonth());
    assertEquals(7, model.getValue().getDate());
}

function test_CalendarModel_attachEvent() {
    var model = new Date.Calendar.Model(new Date("2006/09/16"), Date.EraGroup.DEFAULT_WAREKI);
    var notified = false;
    var f = function(dateModel){
        notified = true;
        assertEquals(Date.Era.SHOWA, dateModel.getValue().getEra());
        assertEquals(1969, dateModel.getValue().getFullYear());
        assertEquals(44, dateModel.getValue().getEraYear());
        assertEquals(9, dateModel.getValue().getMonth());
        assertEquals(7, dateModel.getValue().getDate());
    };
    model.attachEvent(f);
    model.setValue(new Date("1969/10/07"));
    assertTrue("notified", notified);
    notified = false;
    model.detachEvent(f);
    model.setValue(new Date("2010/01/27"));
    assertFalse("notified", notified);
}

function test_CalendarModel_setDate() {
    var model = new Date.Calendar.Model(new Date("2006/09/16"), Date.EraGroup.DEFAULT_WAREKI);
    model.setDate(30);
    assertEquals("20060930", model.getValue().toISODate());
    model.setMonth(10);
    assertEquals("20061030", model.getValue().toISODate());
    model.setEraYear(19);
    assertEquals("20071030", model.getValue().toISODate());
    model.setDate(31);
    assertEquals("20071031", model.getValue().toISODate());
    model.setMonth(9);
    assertEquals("20071001", model.getValue().toISODate());
    model.setEra(Date.Era.SHOWA);
    assertEquals("19441001", model.getValue().toISODate());
}


--></script>

</body>
</html>
